package com.xxxx.server.controller;

import com.xxxx.server.pojo.Admin;
import com.xxxx.server.service.IAdminService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author
 * @version 1.0
 * @date 2020/9/10 10:12
 */
@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private IAdminService adminService;

    @ApiOperation(value = "查询聊天人员列表")
    @GetMapping("/admin")
    public List<Admin> getChatAdmin(){
        final Admin currentAdmin = (Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        currentAdmin.setPassword(null);
        final List<Admin> admins = adminService.selectAdminList("");
        admins.remove(currentAdmin);
        return admins;
    }
}
